//package com.ums.upos;
//
//import android.content.ComponentName;
//import android.content.Context;
//import android.content.Intent;
//import android.content.ServiceConnection;
//import android.os.Bundle;
//import android.os.IBinder;
//import android.os.RemoteException;
//import android.support.test.InstrumentationRegistry;
//import android.support.test.filters.LargeTest;
//import android.support.test.rule.ServiceTestRule;
//import android.support.test.runner.AndroidJUnit4;
//import android.util.Log;
//
//import com.nexgo.common.ByteUtils;
//import com.ums.upos.service.DeviceServiceEngineService;
//import com.ums.upos.uapi.card.mifare.M1CardHandler;
//import com.ums.upos.uapi.card.mifare.M1KeyTypeConstrants;
//import com.ums.upos.uapi.device.pinpad.DesAlgorithmType;
//import com.ums.upos.uapi.device.pinpad.DesMode;
//import com.ums.upos.uapi.device.pinpad.PinPad;
//import com.ums.upos.uapi.device.reader.icc.IccCardReader;
//import com.ums.upos.uapi.device.reader.icc.IccCardType;
//import com.ums.upos.uapi.device.reader.icc.IccReaderSlot;
//import com.ums.upos.uapi.device.reader.icc.OnSearchIccCardListener;
//import com.ums.upos.uapi.engine.DeviceServiceEngine;
//
//import org.junit.After;
//import org.junit.AfterClass;
//import org.junit.Before;
//import org.junit.Rule;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//
///**
// * Created by Administrator on 2017/3/31.
// */
//
//@RunWith(AndroidJUnit4.class)
//@LargeTest
//public class desByTmsKeyTest {
//    //    private static DeviceServiceEngine mDeviceHandle = null;
//    private static PinPad pinPad = null;
//    private DeviceServiceEngine mDeviceHandle = null;
//
//    @Rule
//    public ServiceTestRule mServiceRule = new ServiceTestRule();
//
//    @AfterClass
//    public static void afterall() throws InterruptedException {
//        Thread.sleep(10 * 1000, 0);
//    }
//
//    @After
//    public void afrer() throws InterruptedException {
//        Thread.sleep(10 * 1000, 0);
//    }
//    @Test
//    public void test_desByTmsKey() {
//        try {
//            //需要加密的数据
//            byte[] bytes=new byte[]{0,0,0,0,0,0,0,0};
//            byte[] bytes1 = pinPad.desByTmsKey(7, bytes, bytes.length, DesAlgorithmType.TDES, DesMode.ENCRYPT);
//            Log.d("test_desByTmsKey", "test_desByTmsKey: "+ ByteUtils.byteArray2HexString(bytes1));
//        } catch (RemoteException e) {
//            e.printStackTrace();
//        }
//    }
//    @Before
//    public void start() {
//        Log.d("Test------------","单元测试启动");
//
//        if (null == pinPad) {
//            ServiceConnection conn = new ServiceConnection() {
//
//                @Override
//                public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
//                    mDeviceHandle = DeviceServiceEngine.Stub.asInterface(iBinder);
//
//                }
//
//                @Override
//                public void onServiceDisconnected(ComponentName componentName) {
//                    pinPad = null;
//                }
//            };
//            Intent intent = new Intent(InstrumentationRegistry.getTargetContext(), DeviceServiceEngineService.class);
//            try {
//                mServiceRule.bindService(intent, conn, Context.BIND_AUTO_CREATE);
//                Bundle loginBundle = new Bundle();
//                loginBundle.putInt("workMode", 0);
//                mDeviceHandle.login(loginBundle, "00000001");
//                pinPad=mDeviceHandle.getPinPad();
//                try {
//                    Thread.sleep(10 * 1000, 0);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//
//            } catch (Exception e) {
//                pinPad = null;
//                e.printStackTrace();
//            }
//
//        }
//
//    }
//
//}
